﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using SiGeSIB.Data.Common;

namespace SiGeSIB.GUI.Common
{
	public partial class UFinancesDefaultToolStrip : UserControl
	{
		public UFinancesDefaultToolStrip()
		{
			InitializeComponent();
		}

		private DateTimeInterval _Interval;
		public DateTimeInterval Interval
		{
			get
			{
				return _Interval;
			}
			set
			{
				_Interval = value;
				if (_Interval != null)
					tstbPeriod.Text = _Interval.ToString();
			}
		}

		public event EventHandler GenerateReportRequested;
		public event EventHandler<EventArgs<DateTimeInterval>> IntervalChanged;

		private void OnGenerateRequested()
		{
			if (GenerateReportRequested != null)
				GenerateReportRequested(this, new EventArgs());
		}
		private void OnIntervalChanded()
		{
			if (IntervalChanged != null)
				IntervalChanged(this, new EventArgs<DateTimeInterval>(_Interval));
		}
		private void tsbGenerateReport_Click(object sender, EventArgs e)
		{
			OnGenerateRequested();
		}

		private void tsbPeriod_Click(object sender, EventArgs e)
		{
			FSelectInterval frm = new FSelectInterval();
			if (frm.ShowDialog() == DialogResult.OK)
			{
				Interval = frm.Interval;
				OnIntervalChanded();
			}
		}
	}
}
